package com.example.demo.controller;

import com.example.demo.entity.TUser;
import com.example.demo.service.TUserService;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 测试t_user
 *
 * @author tulc
 */
@RequestMapping("/tUser")
@RestController
public class TUserController {

    @Autowired
    private TUserService tUserService;


    /**
     * 查用户信息
     *
     * @param body
     *      请求体
     *
     * @return
     *      TUser列表
     */
    @RequestMapping("/selectTUserInfo")
    public List<TUser> selectTUserInfo(@RequestBody String body) {
        return tUserService.selectTUserInfo(body);
    }

    /**
     * 测试主键返回
     *
     * @return
     *      主键id
     */
    @RequestMapping("/testKeyGenerate")
    public String testKeyGenerate() {
        return tUserService.testKeyGenerate();
    }

    /**
     * 测试主键返回02
     *
     * @return
     *      主键id
     */
    @RequestMapping("/testKeyGenerate02")
    public String testKeyGenerate02() {
        return tUserService.testKeyGenerate02();
    }

    /**
     * 动态sql测试
     */
    @RequestMapping("/testDynamicSql")
    public String testDynamicSql() {
        return tUserService.testDynamicSql();
    }

    /**
     * 测试批量插入
     */
    @RequestMapping("/testBatchInsert")
    public String testBatchInsert() {
        tUserService.testBatchInsert();
        return "成功";
    }

    /**
     * 测试批量插入02
     */
    @RequestMapping("/testBatchInsert02")
    public String testBatchInsert02() {
        tUserService.testBatchInsert02();
        return "成功";
    }

    /**
     * 测试批量插入03
     */
    @RequestMapping("/testBatchInsert03")
    public String testBatchInsert03() {
        tUserService.testBatchInsert03();
        return "成功";
    }

    /**
     * 测试一对一关联查询的两种方式
     */
    @RequestMapping("/testOneToOne")
    public List<TUser> testOneToOne() {
        List<TUser> tUsers = tUserService.testOneToOne();
        return tUsers;
    }

    /**
     * 测试多参数查询
     */
    @RequestMapping("/testManyParamQuery")
    public String testManyParamQuery() {
        tUserService.testManyParamQuery();
        return "成功";
    }

    /**
     * 测试一对多查询
     */
    @RequestMapping("/testOneToMany")
    public List<TUser> testOneToMany() {
        return tUserService.testOneToMany();
    }

    /**
     * 测试多对多查询
     */
    @RequestMapping("/testManyToMany")
    public List<TUser> testManyToMany() {
        return tUserService.testManyToMany();
    }
}
